<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
	<base href="<%=basePath%>">
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="<%=basePath%>/css/header1_css.css" />
	</head>
	<body>
		<div id="box_main">
			<div id="box_top">
				<a id="homePage" class="actionHome"><img src="img/header_img/house.png" /> 一号店首页</a>
				<ul id="right_box">
					<li style="color: red;">Hi, <a id="activeLogin">${sessionScope.username!=null?sessionScope.username:"请登录"}</a></li>
					<li><a class="link_regs" id="actionRegis">${sessionScope.username!=null?"退出":"注册"}</a></li>
					<li><a id="order">我的订单</a></li>
					<li id="service">
						<a >客户服务</a>
						<div id="hd_menu_list">
							<a id="toShopCenter">商家中心</a><br />
							<a id="toAdminCenter" href="admin_login.jsp">管理员中心</a>
						</div>
					</li>
					<li id="enterprise"><a>企业服务</a></li>
				</ul>
			</div>
			<div id="box_buttom">
				<a class="actionHome"><img id="log" src="img/header_img/log_img.jpg" /></a>
				<div id="serch">
					<input type="text" id="userInput" value=""/> <button id="serch_but"><img src="img/header_img/serch.png"/></button>
					<button id="shopping_cart"><img src="img/header_img/shopping.png" />购物车</button>
				</div>
				<p id="middle">
					<a>四件套</a>
					<a>格兰仕</a>
					<a>澳橙</a>
					<a>蜜柚</a>
					<a>袋子</a>
					<a>塑料箱</a>
					<a>小安素</a>
					<a>沐浴</a>
					<a>黑色酱油</a>
					<a>开福林</a>
				</p>
				<ul id="header_nav">
					<li><a id="active_page1">1号抢购</a></li>
					<li><a id="active_page2">1号团</a></li>
					<li><a>领券中心</a></li>
					<li><a>商城优选</a></li>
					<li><a>全球进口</a></li>
					<li><a>1号生鲜</a></li>
					<li><a>美妆馆</a></li>
					<li><a>家居馆</a></li>
					<li><a>电器城</a></li>
				</ul>
			</div>
		</div>
		<!--<script type="text/javascript" src="js/jquery-3.2.1.js" ></script>-->
		<script type="text/javascript" src="<%=basePath%>/js/jquery-3.2.1.js" ></script>
		<script type="text/javascript" src="<%=basePath%>/lib/layer/2.4/layer.js"></script>
		<script>
			$(function(){
				$('a').hover(
					function(){
						$(this).addClass('aCls');
					},
					function(){
						$(this).removeClass('aCls');
					}
				);
				$('#service').hover(
					function(){
						$(this).addClass('serviceCls');
						$('#hd_menu_list').show();
					},
					function(){
						$(this).removeClass('serviceCls');
						$('#hd_menu_list').hide();
					});
				$('.actionHome').click(function(){
					window.location='search.goods?likeword=';
				});
				$('#activeLogin').click(function(){
					if($(this).html() == '请登录') {
						window.location = "login.jsp";
					}
				});
				$('#actionRegis').click(function(){
					var url;
					/* alert($(this).html()); */
					if($(this).html() == '退出') {
						url = "LoginOutServlet";
					} else {
						url = "regist2.jsp";
					}
					window.location= url;
				});
				$('#shopping_cart').click(function(){
					window.location= 'in.cart';
				});
				$('#serch_but').click(function() {
					var likeword = $('#userInput').val();
					window.location="search.goods?likeword="+likeword;
				});
				$('#order').click(function(){
					if($('#activeLogin').html() != '请登录') {
						myselfinfo();
					}else {
						window.location = "login.jsp";
					}
				});
				$('#shopping_cart').click(function(){
					if($('#activeLogin').html() != '请登录') {
						window.location = "in.cart";
					} else {
						window.location = "login.jsp";
					}
				});
			});
			
			function myselfinfo(){
				var username = $('#activeLogin').html();
				var index = layer.open({
					type: 2,
					time: 0,
					area: ['1200px','600px'],
					fix: ['1200px','600px'], //不固定
					maxmin: true,
					title: '查看信息',
					content: 'MyOrderServlet',
				/* 'MyOrder.jsp?username='+ username */
				});
				layer.full(index);
			}
			
			$('#toShopCenter').click(function(){
				$.ajax({
		               url:"shop.goods",
		               type:"post",  //提交方式，post或get
			 		    async:true, 	//同步或者异步方式，true表示异步，异步方式不会阻塞当前网页,但是会造成处理已经完成但是请求还没完成
		                datatype:'text',
			 			data:{},  //提交的请求参数，是键值对，用：隔开
			 			success:function(redata){ //请求成功的回调函数，参数是响应的返回值
			 				if(redata == 'success') {
			 					window.location = 'shop/shopCenter.jsp';
			 				} else if(redata == 'error'){
			 					alert('你还没有申请店铺，不能进入商品中心');
			 				} else if(redate == 'warning') {
			 					alert('你还没有申请店铺，不能进入商品中心');			 					
			 				}
			 			}
		           });
			});
		    	   
			
		</script>
	</body>
</html>
